const express=require('express')
const api=require('../api/zhl_api')
const userCtler=require('../controller/zhl_userCtrl')
const router=express.Router()
const pageCtrler=require('../controller/zhl_pageCtrl')
const upload=require('../config/zhl_multerConfig')
//登录拦截
router.get('/*.html',function (req,resp,next) {

        if (req.url==='/zhl_login.html'||req.url==='/zhl_register.html'||req.url==='/zhl_canvas.html'){
            next()
        }else {
            if (req.session.u_user!= undefined) {
                console.log(req.session.u_user)
                next()

            } else {
                console.log(11111111)
                resp.redirect('/zhl_login.html')
            }
        }
})
router.get(api.pages.goodsList,pageCtrler.pageCtrl)
router.get(api.DB.userLogin,userCtler.userSelect)
router.get(api.pages.index,pageCtrler.indexCtrl)
router.get(api.DB.outLogin,userCtler.outLoginCtrl)
router.get(api.pages.registerHtml,pageCtrler.registerHtmlCtrl)
router.post(api.DB.register,upload.single('imgSrc'),userCtler.registerCtrl),
router.post(api.DB.delImg,userCtler.delImgCtrl),
router.post(api.DB.filesUpload,upload.array('uploadList',9),userCtler.filesUploadCtrl),
    //我的相册
    router.get(api.DB.showPhoto,userCtler.showPhotoCtrl)
    router.post(api.DB.upCutImg,userCtler.upCutImgCtrl)

module.exports=router